<?php
/* @var $this CustomerquoteController */
/* @var $model Customerquote */


if(!empty($model)){
$this->breadcrumbs=array(
	'Customerquotes'=>array('index'),
	$model->id,
);

$this->menu=array(
	array('label'=>'List Customerquote', 'url'=>array('index')),
	array('label'=>'Create Customerquote', 'url'=>array('create')),
	array('label'=>'Update Customerquote', 'url'=>array('update', 'id'=>$model->id)),
	array('label'=>'Delete Customerquote', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->id),'confirm'=>'Are you sure you want to delete this item?')),
	array('label'=>'Manage Customerquote', 'url'=>array('admin')),
);
?>

<h1>View Customer quote 
<?php
$emailCustomer = "";
$customer = array();
if(!empty($model->customer)){
	echo "(".$model->customer->firstName. " " .$model->customer->lastName .")";
	$emailCustomer = $model->customer->email;
	$customer = $model->customer;
}
?>

<a href="<?php echo Yii::app()->createUrl('/customer/customerquote/update',array('id'=>$model->id));?>" class="btn btn-success btn-large">
	<i class="icon-pencil"></i>
	Edit
</a>
</h1>

<?php $this->widget('zii.widgets.CDetailView', array(
	'data'=>$model,
	'attributes'=>array(
		'id',
		array(
			'name'=>'Product Name',
			'value'=>$gadgetName,
		),
		'price',
		'paymentMethod',
		'createTime',
		'quoteId',
		array(
			'name'=>'status',
			'type'=>'raw',
			'value'=>$model->getStatus($model->id),
		),
		// 'id',
		// 'customerId',
		// 'quoteId',
		// 'quoteDetail',
		// 'price',
		// 'status',
		// 'createTime',
		// 'modifyTime',
		// 'paymentMethod',
		// 'paymentStatus',
		// 'incomingLabelCarrier',
		// 'incomingLabelTrackingCode',
		// 'outgoingLabelCarrier',
		// 'outgoingLabelTrackingCode',
	),
)); 


?>

<br>
<div style="padding:10px; border:1px solid #ebebeb">
		<a href="<?php echo Yii::app()->createUrl('/customer/manage/updateStatus',array('id'=>$model->id,'customer'=>$model->id,'status'=>0));?>" class="btn <?php if(strtolower($model->getStatus($model->id)) == strtolower(Customerquote::ARRSTATUSW) ) echo "btn-danger";else echo "";?> btn-large">
		<?php echo Customerquote::ARRSTATUSW;?>
		</a>
		<a href="<?php echo Yii::app()->createUrl('/customer/manage/updateStatus',array('id'=>$model->id,'customer'=>$model->id,'status'=>1));?>" class="btn <?php if(strtolower($model->getStatus($model->id)) == strtolower(Customerquote::ARRSTATUSR) ) echo "btn-danger";else echo "";?> btn-large">
		<?php echo Customerquote::ARRSTATUSR;?>
		</a>
		<a href="<?php echo Yii::app()->createUrl('/customer/manage/updateStatus',array('id'=>$model->id,'customer'=>$model->id,'status'=>2));?>" class="btn <?php if(strtolower($model->getStatus($model->id)) == strtolower(Customerquote::ARRSTATUSA) ) echo "btn-danger";else echo "";?> btn-large">
		<?php echo Customerquote::ARRSTATUSA;?>
		</a>
		<a href="<?php echo Yii::app()->createUrl('/customer/manage/updateStatus',array('id'=>$model->id,'customer'=>$model->id,'status'=>3));?>" class="btn <?php if(strtolower($model->getStatus($model->id)) == strtolower(Customerquote::ARRSTATUSC) ) echo "btn-danger";else echo "";?> btn-large">
		<?php echo Customerquote::ARRSTATUSC;?>
		</a>




<?php
$quote = array();
$name = "";
if(!empty($model->quote)){
	$quote = $model->quote;
	if(!empty($quote->gadget)){
		$name = $quote->gadget->name;
	}
	
}
if(strtolower($model->paymentMethod)=="paypal"){
	$this->widget('application.extensions.donatebutton.donatebutton', 
		 array(
			   'vertical' => false,
			   'show_frame' => false,
			   'biggerbutton' => false,
			   'fix_amount' => false,
			   'alt_button' => 'Donate',
			   'business' => $emailCustomer,
				'item_name' => $name,
					// 'message' => 'If you like our work, you may throw us some cookies. Donate ',
					'message' => '',
				   'selectable_amount' => array(
						'min_amount'=>0	,
						'max_amount'=>10000,
						'selected_amount'=>(int) $model->price,
						'selected_currency'=>'USD',
						'currencies'=>array('EUR', 'USD'),//or leave ''
					)
		  )
	);
}




?>
<script>
var model = <?php echo @CJSON::encode($customer->attributes);?>;
$().ready(function(e){
	$("#donate_btn").click(function(e){
		// console.log(1);
		$.ajax({
			type:"POST",
			url:"<?php echo Yii::app()->createUrl('/customer/manage/saveLog',array('id'=>$model->id));?>",
			data:model,
			success:function(res){
				console.log(res);
					
			}
		});
		$("#_xxclick").submit();
		
	});
});
</script>
</div>

<?php
if(!empty($customer)){
?>
<hr>
<h1>View Customer #<?php echo $customer->id; ?></h1>
<?php

$this->widget('zii.widgets.CDetailView', array(
	'data'=>$customer,
	'attributes'=>array(
		'id',
		'firstName',
		'lastName',
		'email',
		//'password',
		'street1',
		'street2',
		'city',
		'state',
		'zipCode',
		'country',
		'createTime',
		'lastLoginTime',
	),
));

}
?>


<hr>
<h1>View Log Customer </h1>

<?php 


$this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'customer-grid',
	'dataProvider'=>$modelLog->search($model->id),
	'filter'=>$modelLog,
	'columns'=>array(
		// 'id',
		// 'customerQuoteId',
		'createTime',
		'event',
		'comment',
		array(
			'class'=>'CButtonColumn',
		),
	),
));

}
?>